package cn.hchaojie.camp.javafx.controls;

import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.VPos;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class ContactAddStage extends Application {

	@Override
	public void start(Stage stage) throws Exception {
		Scene scene = new Scene(createContents());
		
		stage.setScene(scene);
		stage.show();
	}
	
	// 在这里创建页面布局
	private Parent createContents() {
		GridPane grid = new GridPane();
		grid.setVgap(10);
		grid.setHgap(10);
		grid.setPadding(new Insets(20));
		
		Label labelName = new Label("姓名：");
		TextField txtName = new TextField();
		
		Label labelPhone = new Label("电话：");
		TextField txtPHone = new TextField();
		
		Label labelNote = new Label("备注：");
		TextArea txtNote = new TextArea();
		
		grid.add(labelName, 0, 0);
		grid.add(txtName, 1, 0);
		grid.add(labelPhone, 0, 1);
		grid.add(txtPHone, 1, 1);
		grid.add(labelNote, 0, 2);
		grid.add(txtNote, 1, 2);
		GridPane.setConstraints(labelNote, 0, 2, 1, 1, HPos.CENTER, VPos.TOP);
		
		HBox box = new HBox(10);
		box.setAlignment(Pos.CENTER_RIGHT);
		
		Button ok = new Button("确定");
		Button cancel = new Button("取消");
		box.getChildren().addAll(ok, cancel);
		grid.add(box, 1, 3);

		return grid;
	}

	public static void main(String[] args) {
		launch(args);
	}
}
